package treeview.unit;

import document.Context;
import search.Visitor;

import java.awt.*;

/**
 * Created by Pavel Nikolaev
 */
public final class ImageView extends ContextDependentView {
    private int myImageHeight;
    private int myImageWidth;

    public ImageView(Context context) {
        super(context);
        myImageHeight = myContext.getImageDefaultHeight();
        myImageWidth = myContext.getImageDefaultHeight();
    }

    public void fitIntoWidth(Graphics g, int widthToFitInto) {
        myWidth = myContext.getImageDefaultWidth();
        myDescent = 0;
        myAscent = myImageHeight;
        myHeight = myImageHeight;
    }

    public void paint(Graphics g) {
        g.drawRect(myX, myY, myImageWidth, myImageHeight);
    }

    @Override
    public void accept(Visitor visitor) {
        visitor.visitImageView(this);
    }
}
